﻿<!DOCTYPE html>
<html lang="zh" style="background-color: #fff;">
<head>
<meta charset="utf-8" />
<title>数据管理</title>
<link rel="stylesheet" href="${mvcPath}/dacp-view/aijs/css/ai.css" type="text/css" />
<link rel="stylesheet" href="${mvcPath}/dacp-lib/fuelux/fuelux.min.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${mvcPath}/dacp-res/catalog/common/css/ai.meta.css" type="text/css" />
<link rel="stylesheet" href="${mvcPath}/dacp-res/catalog/common/css/search.css" type="text/css"/>
<link rel="stylesheet" href="${mvcPath}/dacp-res/catalog/common/css/ai.serach.css" type="text/css" />
<link rel="stylesheet" href="${mvcPath}/dacp-res/catalog/common/css/ai.advancefilter.css" type="text/css"/>
<script src="${mvcPath}/dacp-lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery-ui-1.10.2.min.js" type="text/javascript"></script> 
<script src="${mvcPath}/dacp-lib/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${mvcPath}/dacp-lib/underscore/underscore-min.js" type="text/javascript"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery.tmpl.min.js"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery-contextMenu.js"></script>
<script src="${mvcPath}/dacp-lib/fuelux/fuelux.min.js"></script>
<script src="${mvcPath}/dacp-lib/jquery-plugins/jquery.isotope.js"></script>
<script src="${mvcPath}/dacp-lib/gojs/go.js"></script>
<script src="${mvcPath}/dacp-lib/cryptojs/aes.js" type="text/javascript"></script>
<script src="${mvcPath}/crypto/crypto-context.js" type="text/javascript"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.core.js"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.jsonstore.js"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.field.js"></script>
<script src="${mvcPath}/dacp-view/aijs/js/ai.grid.ux.js"></script>
<script src="${mvcPath}/dacp-res/catalog/common/js/ai.meta.widget.js"></script>
<script src="${mvcPath}/dacp-res/catalog/common/js/parabola.js"></script>
<script src="${mvcPath}/dacp-res/catalog/common/js/ai.widget.js"></script>
<script src="${mvcPath}/dacp-res/catalog/common/js/ai.serach.js"></script>
<script src="${mvcPath}/dacp-res/catalog/common/js/ai.advancefilter.js"></script>
<script src="${mvcPath}/dacp-res/catalog/dataindex/js/ai.dataindex.page.js"></script>
<style>
	.ui-layout-west {
		background:#f3f3f3;
	}
	.pop {
		left:190px;
	}
	#nav-list ul li dd {
		margin-left:12px;
	}
	#nav-list ul li dt {
		width:0px;
	}
	.fl {
		float:left;
	}
	.fr {
		float:right;
	}
	.head-area {
		height:70px;
		margin-left:5px;
		margin-right:5px;
		padding-top:20px;
	}
	.logo-header {
		float:left;
		padding-left:100px;
		padding-right:30px;
	}
	.logo-dacp {
		margin-right:10px;
	}
	.logo-dacp > img {
		width:45px;
		height:31px;
		margin-bottom:15px;
	}
	.logo-title {
		color:#47B2FB;
		font-size:20px;
	}
	.dacp-detail {
		float:right;
		margin-right:40px;
	}
	.quick-icon,.open-icon,.quality-icon {
		width:20px;
		height:20px;
		display:block;
		background-repeat:no-repeat;
		background-size:contain;
		margin:0 15px 2px 15px;
	}
	.quick-icon {
		background-image:url("${mvcPath}/dacp-res/catalog/dataportal/images/icon-quick.png");}
	.open-icon {
		background-image:url("${mvcPath}/dacp-res/catalog/dataportal/images/icon-open.png");}
	.quality-icon {
		background-image:url("${mvcPath}/dacp-res/catalog/dataportal/images/icon-quality.png");}
	.d_detail {
		padding:5px;
		font-size:10px;
		color:#B3B3B3;
	}
	.clear-both {
		clear:both;
		height:0;
		overflow:hidden;
	}
	.close {
		margin-top: 0px;
	}
	/********************************************************/
	.nav-area {height:auto;border-bottom:2px solid #47B9FC}
	#topMenu1 {
	width:1210px;
    margin: 0 auto;
    float:none;
}
#topMenu1 .list{background-color:#47B9FC;}
#topMenu1 a{    line-height: 18px;font-size:15px;font-family:microsoft yahei;}
#topMenu1 .active a{color:#47B9FC;}
.caret{    margin-left: 60px;
    vertical-align: middle;
    border-top: 8px solid;
    border-right: 8px solid transparent;
    border-left: 8px solid transparent;}
    
#topMenu1>li>a:hover,#topMenu1>li>a:focus {
	color: #47B9FC;
}
/*
.nav>li>a:hover, .nav>li>a:focus {
    background-color: #fff;
}
*/
#nav-list>a:hover,#nav-list>a:focus{background-color: #47B9FC;}
#all-menu{width:210px;background-color:#47B9FC;color: #fff;max-height:600px;}
#all-menu a{font-size:14px;color:#fff;}
#tabcontent{width:1210px;margin:0 auto;}

#nav-list ul li{zoom:1;clear:both;cursor:default}
#nav-list ul li .tx{line-height:35px;background-color:#47B9FC;padding-left:10px;background-repeat:no-repeat;background-position:right center;height:35px;_background-image:none}
#nav-list ul li .tx a{ color:#fff;font-size:14px;-webkit-transition:color 0.1s ease-out 0s;-moz-transition:color 0.1s ease-out 0s;-ms-transition:color 0.1s ease-out 0s;-o-transition:color 0.1s ease-out 0s;transition:color 0.1s ease-out 0s}
#nav-list ul li .tx a i{line-height:25px;margin-top:3px; background-position:0px 0px;float:left;height:25px;margin-right:2px;text-decoration:none}
 
#nav-list ul li dl{zoom:1;color:#fff;clear:both;overflow:auto;margin-bottom:0px;}
/* #nav-list ul li dl a{line-height:22px;width:60px;white-space:nowrap;float:left;color:#000;margin-left:6px;margin-right:6px;-webkit-transition:color 0.1s ease-out 0s;-moz-transition:color 0.1s ease-out 0s;-ms-transition:color 0.1s ease-out 0s;-o-transition:color 0.1s ease-out 0s;transition:color 0.1s ease-out 0s} */
#nav-list ul li dl a.active{background: #47B9FC; color: white;}
/*#nav-list ul li dt{padding-left:10px;width:30px;float:left;padding-top:1px;font-size:5px}*/
#nav-list ul li dd{line-height:22px; float:left;}
#nav-list ul li .pop{border-bottom:#599900 2px solid;position:absolute;border-left:medium none;padding-bottom:10px;background-color:#47B9FC;min-height:466px;padding-left:30px;width:640px;padding-right:30px;display:none;height:464px;border-top:medium none;top:0px;border-right:#599900 2px solid;padding-top:10px;left:215px;box-shadow:4px 4px 5px -1px #999999;-webkit-box-shadow:4px 4px 5px -1px #999999;-moz-box-shadow:4px 4px 5px -1px #999999}
#nav-list ul li .pop h3{display:none;font-size:14px}
#nav-list ul li .pop dl{padding-bottom:6px;color:#fff;padding-top:6px}
#nav-list ul li .pop dl:hover{background-color:#47B9FC}
#nav-list ul li .pop dl a{color:#fff;margin-left:12px;margin-right:2px;min-width: 50px;white-space: initial !important;}
#nav-list ul li .pop dl a.un{color:#fff}
#nav-list ul li .pop dt{padding-left:0px;width:72px}
#nav-list ul li .pop dd{width:565px;margin-left:-12px}
#nav-list ul li .pop .act{width:640px;height:80px;overflow:hidden;padding-top:10px}
#nav-list:hover ul{display:block}
#nav-list ul li:hover{background-color:#47B9FC;}
#nav-list ul li:hover .tx{background-color:#47B9FC}
#nav-list ul li:hover .tx a{color:#fff}
#nav-list ul li:hover .tx a i{background-position:0px -25px}
#nav-list ul li:hover .pop{display:block;top:0px;left:210px}
#nav-list ul li:hover .pop dl a.un{color:#a5a5a5;text-decoration:none}
#nav-list ul li:hover dl{color:#000}
/*#nav-list ul li:hover a{color:#000}*/
#nav-list ul li:hover a:hover{color:#000}


#nav-list ul li .tx a {
    color: #fff;
    font-size: 14px;
    transition: color 0.1s ease-out 0s;
}
#nav-list ul li dl a {
    line-height: 22px;
    min-width: 40px;
/*     max-width:50px; */
    white-space: nowrap;
    float: left;
    color: #fff;
    margin-left: 3px; 
    margin-right: 3px;
    -webkit-transition: color 0.1s ease-out 0s;
    -moz-transition: color 0.1s ease-out 0s;
    -ms-transition: color 0.1s ease-out 0s;
    -o-transition: color 0.1s ease-out 0s;
    transition: color 0.1s ease-out 0s;
    font-size: 12px;
    font-weight: normal;
}


.nui-infoBlock {
    font-size: 14px;
    color: #999;
    padding: 20px;
    border-radius: 3px;
    border: 1px solid #E5E5E5;
    background: #FAFAFA;
    margin: 20px 0px;
}
.nui-block-content p{margin:0;font-size:12px;}
.sX0 {
    border-radius: 3px 3px 0 0;
    padding: 0 10px;
    height: 34px;
    line-height: 34px;
    margin-top: 0;
    background: #E9E9E9;
    overflow: hidden;
    position: relative;
}
.sX0 a{float:none;}
.tab-drag-container{
	margin-top:20px;
	padding: 0 10px;
}
.tab-drag-container li{
	margin-bottom: 14px;
    border: 1px solid #999!important;
    border-radius: 0;
    margin-right: 4px;
    cursor: move;
    padding-top: 6px;
    padding-bottom: 0
}

.tab-pane{
	height:1000px;
}

#sortable .my-sortable-item {
	margin-bottom: 14px;
	border: 1px solid #999 !important;
	border-radius: 0;
	margin-right: 4px;
	cursor: move;
	padding-top: 6px;
	padding-bottom: 0;
	background-position: 0 -496px;
	z-index: 4;
	color: #333;
	background-repeat: repeat-x;
	outline: 0;
	float: left;
	position: relative;
	height: 30px;
	width: 110px;
	text-align: center;
	line-height: normal;
	font-size: 14px;
	padding: 7px 20px 2px 8px;
	-webkit-user-select: none;
	opacity: 1;
	list-style: none;
}
#sortable .inner-span {
	text-overflow: ellipsis;
	color: #555;
	display: block;
	width: 100%;
	white-space: nowrap;
	position: relative;
	overflow: hidden;
	line-height: 16px;
	-webkit-user-select: none;
	font-size: 14px;
}
.tips {
	margin-bottom: 14px;
	text-align: left;
	color: #999;
	padding: 6px 12px;
	border-color: #e7e7cd;
	background: #ffffe1;
	font-size: 12px;
	line-height: 1.666;
	border: 1px solid #bdbdbd;
	position: relative;
}
#sortable .close-link {
	top: -4px;
	right: -3px;
	width: 14px;
	height: 14px;
	padding: 0;
	color: #FFF !important;
	position: absolute;
	line-height: 0;
	font-size: 0;
	cursor: move;
	text-align: center;
}
#sortable .red-close {
	top: 3px;
	left: 4px;
	cursor: pointer;
	width: 14px;
	height: 14px;
	background: url(../../../dacp-res/catalog/common/images/redclose.png) no-repeat;
	font-weight: 400;
	text-align: center;
	overflow: hidden;
	display: inline-block;
}
#for-choose-ul {
	margin: 12px;
	padding: 0;
	list-style: none;
}
#for-choose-ul .content {
	margin: 6px 0;
	width: 180px;
	display: inline-block;
	vertical-align: middle;
}
#for-choose-ul .add-div {
	line-height: normal;
	display: inline-block;
	vertical-align: middle;
}
#for-choose-ul .add-a {
	position: relative;
	outline: 0;
	cursor: pointer;
	padding: 2px 4px 4px;
	text-decoration: none;
	border-radius: 3px;
	line-height: normal;
	font-size: 12px;
}
#for-choose-ul .add-icon {
	cursor: pointer;
	position: absolute;
	left: -18px;
	top: 1px;
	width: 16px;
	height: 16px;
	background: url(../../../dacp-res/catalog/common/images/greenadd.png) no-repeat;
	font-weight: 400;
	text-align: center;
	overflow: hidden;
	font-family: nui !important;
	font-size: 12px;
	font-style: normal;
	line-height: normal !important;
	display: inline-block;
	vertical-align: middle;
}
.repeater-list .table td, .repeater-list .table th {
    padding: 8px 15px;
    border-top: 1px solid #eaeef1;
}
.repeater-title .total{color:red;margin-left:5px;}
</style>

<!-- todo 每次要不要重新加载 
	 搜索框中，点击搜索应该重新加载页面
	 筛选栏中，点击搜索不需要重新加载
	 url中传过来的参数的有效期（包括搜索框）
	 
	 不同的搜索框，关键字的查询字段不同，怎么适配
-->
<script type="text/javascript">
paramMap['prod']='dataos';
var metaprj = paramMap.metaprj||'';

//中英文处理
var baseStore = ai.getJsonStore("select dbname,cnname from metadb_list ");
var cycleStore = ai.getJsonStore("select rowcode,rowname from metaedimdef where dimcode ='DIM_TAB_CYCLE'");
var topicStore = ai.getJsonStore("select rulecode,rulename from metadb_struct WHERE DBNAME = 'METADB'");
var typeStore = ai.getJsonStore("select objtype, objname from metaobjmodel where 1=1");

try{
    jQuery.parseJSON(localStorage.dataclg_user_tab);
    if(!new RegExp("^\\[.*\\]$").test(localStorage.dataclg_user_tab)) {
    	localStorage.dataclg_user_tab = "";
    }
} catch(e) {
	localStorage.dataclg_user_tab = "";
}

var MainSheet = null;
var MainFram = Event.$extend({
	meta: null,
	metaModel: null,
	allCatalogs: [],
	fixedTab: localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [],
	__init__: function(options) {
		this.init(options);
	},
	init: function(options) {
		this.buildSerachWrap();
		MainSheet = new AI.MainSheet({
			headId: 'topMenu1',
			contentId: 'tabcontent'
		});
		this.buildCatalogMenu();
		this.buildCatalogFixTab();
		this.bulidCatalogContent('TAB');
	},
	buildSerachWrap:function(){//构建搜索栏
		serachWrap = new AI.Serach({
			containerId: "serach-input-wrap",
			showHotword: false,
			clickFunc: function() {
				console.log(dataindex.querysql);
				var keyword = $("#keyword").val();
				if (!keyword) keyword='%%';
				/*
				$(".media li>a").removeClass("active");
				$(".media-body>ul>li:first-child>a").addClass("active");
				var where = "";
				if (dataindex.querysql.toLowerCase().indexOf(" where ") == -1) {
					where += " where ";
				}else where += " and ";
				where += "((dataname like '%" + keyword + "%' or dataname like '%" + keyword.toUpperCase() + "%')" + " or (datacnname like '%" + keyword + "%' or datacnname like '%" + keyword.toUpperCase() + "%'))";
				dataindex.listView.reload(dataindex.querysql + where);
				*/
				//MainSheet.addTabSheet("tab-search", "搜索", "", true, null, null, true);
				//$("#topMenu1>li:last-child").find("a").click();
				var objtype = $("#topMenu1 li.active a").attr('href').split('-')[1];
				dataindex = new AI.Dataindex({
					//objtype: 'META',
					objtype:objtype,
					//containerId: 'tab-search',
					containerId: 'tab-'+objtype,
					filterParam:{objname:keyword},
					metaprj:metaprj
				});
			}
		});
	},
	buildCatalogMenu:function(){//构建数据目录分类
		this.allCatalogs = [];
		var tmplHtml = '<li class="" objtype="{PARENT-TYPE}" filter=""> '
				+'<div class="tx"> <a href="#href" id="" ><i class="glyphicon glyphicon-th-large"></i>{PARENT-NAME}</a> </div>'
				+'<dl><dt></dt>'
				+'	<dd>'                     
				+'		<% _.each(datas, function(item) { %> ' 
				+'			<a id="<%= item.objtype %>" objtype="<%= item.objtype %>"><%= item.objname %></a> ' 
				+'		<% }); %>'                       
				+'	</dd>     '  
				+'</dl>   '               
				+'</li>';
		//1.从元模型构建,不需要权限的控制
		var parentStore = new AI.JsonStore({
			sql: "select objtype, objname, parentcode from metaobjmodel where parentcode = 'META' and objtype <> 'META-OTHER' and state = 'Y' order by ordseq",
			pageSize: -1,
			table: "METAOBJMODEL",
			key: "OBJTYPE"
		});
		for(var i=0; i<parentStore.getCount(); i++) {
			var rec = parentStore.getAt(i);
			var subTmpl = tmplHtml.replace("{PARENT-TYPE}", rec.get("OBJTYPE")).replace("{PARENT-NAME}", rec.get("OBJNAME"));
			var storedata = ai.getStoreData("select objtype, objname, parentcode from metaobjmodel where state = 'Y' and parentcode = '" + rec.get("OBJTYPE") + "' order by ordseq");
			var datas = [];
			for(var j=0; j<storedata.length; j++) {
				var data = {
					objtype: storedata[j].OBJTYPE,
					objname: storedata[j].OBJNAME
				};
				datas.push(data);
				this.allCatalogs.push(data);
			}
			var li = _.template(subTmpl)({'datas':datas});
			$("#all-menu").append(li);
		}

		//2.从数据专辑构建,需要考虑权限的控制,是否发布使用,是否为公有目录,私有目录需要控制角色或者个人
		/*
		发布与不发布  可用或不可用
		公有与私有  是说是全部都可以看还是部分或者创建人才可以看
		*/
		var catalogTmpl = tmplHtml.replace("{PARENT-TYPE}", "META-CUSTOM").replace("{PARENT-NAME}", "数据专辑");
		var catalogData = ai.getStoreData("select catalog_code, catalog_name, catalog_right, user_list, user_role, state from data_catalog_def where state = '发布' order by ordseq");
		catalogData = catalogData ? catalogData : [];
		var datas = [];
		for(var i=0; i<catalogData.length; i++) {
			var catalogRight = catalogData[i].CATALOG_RIGHT;
			if(catalogRight == "私有") {
				var creater = catalogData[i].CREATER;
				var userList = catalogData[i].USER_LIST;
				var userRole = catalogData[i].USER_ROLE;
				var curUser = _UserInfo['username'];
				console.log(curUser);
				var hasRight = false;

				if(creater && curUser == creater) {
					hasRight = true;
				}

				if(userList && userList.indexOf(curUser) != -1) {
					hasRight = true;
				}

				if(userRole) {
					var curUserRoles = ai.getStoreData("select groupcode from metagroupuser where username = '" + curUser + "'");
					for(var j=0; j<curUserRoles.length; j++) {
						var role = curUserRoles[j].GROUPCODE;
						if(userRole.indexOf(role) != -1) {
							hasRight = true;
							break;
						}
					}
				}	

				if(!hasRight) {
					continue;
				}
			}

			var data = {
				objtype: catalogData[i].CATALOG_CODE,
				objname: catalogData[i].CATALOG_NAME 
			};
			datas.push(data);
			this.allCatalogs.push(data);
		}
		$("#all-menu").append(_.template(catalogTmpl)({'datas':datas}));

		$("#all-menu").append('<li class="" objtype=META-CUSTOM filter="">' 
							+ '<div class="tx"> <a href="javascript:void(0);" id="tabsheetConfig" style="color:red;"><i class="glyphicon '
							+ 'glyphicon-tag"></i>管理默认标签</a> </div>'
							+ '	</li>');
	},
	buildCatalogFixTab: function(){//构建默认的横向固定Tab
		var len = $("#topMenu1").children("li.dropdown").length;
		for(var i=2; i<len; i++) {
			$("#topMenu1").children("li:eq(2)").remove();
		}
		var tabTempHtml = '<% _.each(datas, function(item) { %>' +
							'<li class="dropdown" id="<%=item.objtype%>-menu">' +
								'<a href="#tab-<%=item.objtype%>" data-toggle="tab" id="<%=item.objtype%>-a" class="generate">' +
									'<span class="" aria-hidden="true"></span>' +
									'<%=item.objname%>' + 
								'</a>' +
						  	'</li>' + 
						  '<% }); %>'; 
		$("#TAB-menu").after(_.template(tabTempHtml)({'datas': this.fixedTab}));

		var contentDivTempHtml = '<% _.each(datas, function(item) { %>' +
									'<div class="tab-pane" id="tab-<%=item.objtype%>"></div>' +
								 '<% }); %>'; 
		$("#tabcontent").append(_.template(contentDivTempHtml)({'datas': this.fixedTab}));

		$("#topMenu1 .generate").click(function(){
			serachWrap.reset();

			var objtype = this.id.replace("-a", "");
			dataindex = new AI.Dataindex({
				objtype: objtype,
				containerId: 'tab-' + objtype,
				metaprj: metaprj
			});
			$(this).tab("show");
		});
	},
	bulidCatalogContent: function(_code) {
		dataindex = new AI.Dataindex({
			objtype: _code,
			containerId: 'tab-' + _code,
			filterParam:{objname:''},
			metaprj: metaprj
		});
	},
	buildSheetConfig: function() {
		this.fixedTab = localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [];
		var self = this;

		$("#tab-config").remove();

		var html = '<div class="tab-pane" id="tab-config">' + 
						'<div class="row nui-infoBlock" >' +
							'<div class="col-md-1"><span class="glyphicon glyphicon-edit" style="font-size:60px;"></span></div>' +
							'<div class="col-md-10">' +
								'<div style="color:#555;margin-top: 5px;">多标签窗口</div>' +
								'<div class="nui-block-content">' +
									'<p>支持通过个性化配置，自定义实现数据目录和详情页的多窗口浏览，</p>' +
									'<p>还可以自主决定固定出现在窗口栏中的功能和目录并进行排序。</p> ' +             
								'</div>' +
							'</div>' +
						'</div>' +
						'<div class="sX0">' + 
							'<b>管理已固定的标签窗口</b>' +
							'<span style="color:#999;">（可用鼠标拖动以下标签进行排序）</span>' +
							'<a id="reset" href="javascript:void(0)">全部恢复默认</a>' +
						'</div>' +
						'<div class="tab-drag-container">' +
							'<ul id="sortable" class="nav hidden-xs navbar-nav " style="float:none;">' +
							'</ul>' +
						'</div>' +
						'<div class="tips">温馨提示：点击标签上方的“x”可以把该标签设为不在默认状态下显示。</div>' +
						'<div class="sX0"><span>你还可以添加以下应用为固定标签窗口</span></div>' +
						'<ul id="for-choose-ul">' +
						'</ul>' +
					'</div>';	
		var tabConfig = $(html);
		tabConfig.find("#reset").click(function(event) {
			localStorage.dataclg_user_tab = "";
			self.fixedTab = [];
			self.buildCatalogFixTab();
			self.buildSheetConfig();
		});

		var choosenLiHtml = '<% _.each(datas, function(item) { %>' +
								'<li id="<%=item.objtype%>" objtype="<%=item.objtype%>" class="my-sortable-item">' +
									'<span class="inner-span" aria-hidden="true"><%=item.objname%></span>' +
									'<a id="<%=item.objtype%>_close" href="javascript:void(0)" class="close-link" title="点击移除固定标签">' +
										'<span class="red-close"></span>' +
									'</a>' +
								'</li>' + 
							'<% }); %>'; 
		tabConfig.find("#sortable").append(_.template(choosenLiHtml)({'datas': this.fixedTab}));
		tabConfig.find("#sortable .close-link").click(function(event) {
			var objtype = this.id.replace("_close", "");
			self.deleteInLocalStorage(objtype);
			self.buildCatalogFixTab();
			self.buildSheetConfig();
		});

		var forChooseLiHtml = '<% _.each(datas, function(item) { %>' +
								  '<li id="<%=item.objtype%>">' +
									'<div class="content">' +
										'<b id="" class="" style="margin-right:5px">' + 
											'<i class="glyphicon glyphicon-list-alt"></i>' +
										'</b>' +
										'<%=item.objname%>' +
									'</div>' +
									'<div class="add-div">' +
										'<a id="<%=item.objtype%>_add" href="javascript:void(0)" class="add-a">' +
											'<b class="add-icon"></b>添加' +
										'</a>' +
									'</div>' +
								  '</li>' + 
							   '<% }); %>'; 

		var forChooseCatas = [];
		for(var i=0; i<this.allCatalogs.length; i++) {
			var cata = this.allCatalogs[i];
			if(cata.objtype == 'TAB') {
				continue;
			}

			if(!this.findInLocalStorage(cata.objtype)) {
				forChooseCatas.push(cata);
			}
		}
		tabConfig.find("#for-choose-ul").append(_.template(forChooseLiHtml)({'datas':forChooseCatas}));
		tabConfig.find("#for-choose-ul .add-a").click(function(event) {
			var objtype = this.id.replace("_add", "");
			self.addLocalStorage(objtype);
			self.buildCatalogFixTab();
			self.buildSheetConfig();
		});

		$("#tabcontent").prepend(tabConfig);

		$("#sortable").sortable({
			items: '.my-sortable-item',
			opacity: 0.9,
			helper: 'original',
			revert: true,
			axis:'x',
			update : function(event, ui){       //更新排序之后
				self.fixedTab = localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [];
				var idArr = $(this).sortable("toArray");
				var newArr = [];
				for(var i in idArr) {
					var objtype = idArr[i];
					var data = self.findInLocalStorage(objtype);
					if(data) {
						data.seq = i;
						newArr.push(data);
					}
				}
				self.fixedTab = newArr;
				localStorage.dataclg_user_tab = JSON.stringify(self.fixedTab);
				self.buildCatalogFixTab();
			}
		});
		$('#tab-config').addClass('active');
	},
	buildSideButton: function() {
		installBottomSideButton();
	},
	buildShopCart: function() {
		buildShopCart();
	},
	findInLocalStorage: function(objtype) {
		this.fixedTab = localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [];
		for(var i=0; i<this.fixedTab.length; i++) {
			if(this.fixedTab[i].objtype == objtype) {
				return this.fixedTab[i];
			}
		}
		return null;
	},
	addLocalStorage: function(objtype) {
		this.fixedTab = localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [];
		var objname = "";
		for(var i in this.allCatalogs) {
			if(this.allCatalogs[i].objtype == objtype) {
				objname = this.allCatalogs[i].objname;
			}
		}
		var data = {objtype: objtype, objname: objname, seq: this.fixedTab.length};
		this.fixedTab.push(data);
		localStorage.dataclg_user_tab = JSON.stringify(this.fixedTab);
	},
	deleteInLocalStorage: function(objtype) {
		this.fixedTab = localStorage.dataclg_user_tab ? jQuery.parseJSON(localStorage.dataclg_user_tab) : [];
		var newArr = [];
		var seqCount = 0;
		for(var i in this.fixedTab) {
			var data = this.fixedTab[i];
			if(data.objtype != objtype) {
				data.seq = seqCount;
				seqCount++;
				newArr.push(data);
			}
		}
		this.fixedTab = newArr;
		localStorage.dataclg_user_tab = JSON.stringify(this.fixedTab);
	}
});
	
$(document).ready(function() {
	viewIndex = new MainFram({
		containerId: 'content-area'
	});
	$("#mydatamgr").click(function() {
		var _url = '/' + contextPath + '/ftl/dataindex/ai.data.indexfrm?tpl=HFlatTreeTabpanel&prodcode=DATA_PORTAL_00';
		window.open(_url, 'mydatamgr');
	});

	//点击目录列表的选项加载对应内容
	$("#all-menu dd a").click(function() {
		
		var _code = $(this).attr("objtype");
		var _name = $(this).html();
		var _type = $(this).parents('li').attr("objtype");
		MainSheet.addTabSheet("tab-" + _code, _name, "", true, null, null, true);
		$("#topMenu1>li:last-child").find("a").click();
		if(_type=='META-CUSTOM'){
			dataindex = new AI.Dataindex({
				objtype: 'META',
				containerId: 'tab-' + _code,
				casetype:'custom',
				filterParam:{dbname:_code},
				metaprj: metaprj
			});
		}else{
			dataindex = new AI.Dataindex({
				objtype: _code,
				containerId: 'tab-' + _code,
				filterParam:{objname:''},
				metaprj: metaprj
			});
		}
		
		$("a[href='#tab-"  + _code + "']").click(function(){
			serachWrap.reset();
			$(this).tab("show");
			dataindex = new AI.Dataindex({
				objtype: _code,
				containerId: 'tab-' + _code,
				filterParam:{objname:''},
				metaprj: metaprj
			});
		});
	});

	$('#tabsheetConfig').click(function(){
		viewIndex.buildSheetConfig();
		MainSheet.addTabSheet("tab-config", "设置", "", true, null, null, true);
		$("#topMenu1>li:last-child").find("a").click();
	});

});
</script>
</head>
<body>
	<div class="head-area">
		<div class="logo-header">
			<a href="#" class="logo-dacp">
				<img src="${mvcPath}/dacp-res/catalog/dataportal/images/logo-dacp.png" alt="到首页" title="到首页"></a>
			<span class="logo-title">数据资产云图</span></div>
		<div id="serach-input-wrap" class="fl"></div>
		<div class="fr dacp-detail">
			<div class="fl d_detail">
				<span class="quick-icon"></span>高效便捷</div>
			<div class="fl d_detail">
				<span class="open-icon"></span>安全开放</div>
			<div class="fl d_detail">
				<span class="quality-icon"></span>质量保证</div>
		</div>
	</div>
	<div id="content-area">
		<div class="nav-area">
		<ul class="nav hidden-xs navbar-nav " id="topMenu1" role="banner">
			<li class="dropdown list" id="nav-list">
				<a href="#" class="dropdown-toggle lt" data-toggle="dropdown" style="width: 210px;text-align: left;color:#fff;">
					<span class="" aria-hidden="true"></span>全部目录分类 <b class="caret"></b>
				</a>
				<ul style="" class="dropdown-menu animated fadeInRight " id="all-menu">
					
				</ul>
			</li>
			<li class="dropdown active" id="TAB-menu">
				<a href="#tab-TAB" data-toggle="tab" id="TAB-a">
					<span class="" aria-hidden="true"></span>
					数据资源</a>
			</li>
		</ul>
		</div>
		<div class="clear-both"></div>
		<div id="tabcontent" class="tab-content">
			<div class="tab-pane active" id="tab-TAB"></div>
		</div>
	</div>
	<!--底部-->
	<div class="g_ft" id="g_ft"></div>
	<!--底部结束-->
</body>

</html>